home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / a_utils / perl / prlbkxmp.lha / ch2 / reproach < prev    next >
Text File  |  1991-01-07  |  496b  |  28 lines

  1. #!/usr/bin/perl
  2.  
  3. $_ = <STDIN>;
  4.  
  5. if (!/camels (\d+)/) {
  6.     print STDERR "Incorrect format--please try again!\n";
  7.     $errors++;
  8. }
  9. if ($1 <= 0) {
  10.     print STDERR "Incorrect format--please try again!\n";
  11.     $errors++;
  12. }
  13. if (/pigs/) {
  14.     print STDERR "Incorrect format--please try again!\n";
  15.     $errors++;
  16. }
  17.  
  18. # Alternate approach
  19.  
  20. &reproach if !/camels (\d+)/;
  21. &reproach if $1 <= 0;
  22. &reproach if /pigs/;
  23.  
  24. sub reproach {
  25.     print STDERR "Incorrect format--please try again!\n";
  26.     $errors++;
  27. }
  28.